Skip to content

Generate contract specs as const ScSpecEntryRef - #1964

Closed
leighmcculloch wants to merge 1 commit into
extract-shared-type-spec-genfrom
spec-xdr-const-ref-codegen
Closed

Generate contract specs as const ScSpecEntryRef#1964
leighmcculloch wants to merge 1 commit into
extract-shared-type-spec-genfrom
spec-xdr-const-ref-codegen

Conversation

@leighmcculloch

@leighmcculloch leighmcculloch commented Jul 29, 2026

Copy link
Copy Markdown
Member

What

Generate every contract spec entry — types, events, and functions — as a const ScSpecEntryRef value that the contract crate encodes to XDR at compile time, instead of encoding it inside the macro and emitting an opaque byte-string literal.

Why

The spec a macro produces is currently invisible in expanded code and unreachable from Rust, so it can only be inspected by decoding the bytes out of the built wasm; a const value can be read in cargo expand and reused by other generated code. Spec section bytes are unchanged for all 43 test contracts.

Known limitations

Depends on stellar/rs-stellar-xdr#562 for the borrowing *Ref types and their const XDR serializers, so this carries a [patch.crates-io] pin on a stellar-xdr git rev until that lands and is released. Spec shaking still encodes the spec at macro time to compute its marker hash.

@leighmcculloch

Copy link
Copy Markdown
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant